package com.itheima.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class Test04 {
    public static void main(String[] args) throws IOException {
        //获取路径
        String path = Test04.class.getClassLoader().getResource("student.xml").getPath();
        Document document = Jsoup.parse(new File(path), "utf-8");
        //通过Element对象获取子标签对象
        Element element = document.getElementsByTag("student").get(0);
        Elements name = element.getElementsByTag("name");
        System.out.println(name.size());
        //获取student对象的属性值
        String number = element.attr("NUMBER");
        System.out.println(number);
        System.out.println("------------");
        //获取文本内容
        String text = name.text();
        String html = name.html();
        System.out.println(text);
        System.out.println(html);


    }
}
